******************************
* Stata preamble
******************************
capture log close
set linesize 255
set mat 1500
set more off,perm
sysdir
mata: mata mlib index
set scheme plotplainblind
global G gstats tab
global S stats(mean sd min p1 q p99 max n)

			*************************
			* Program -- Winsorize
			*************************	
			capture program drop WinStd_tb
				program define WinStd_tb
				disp "Creating Winsorized (w_) and Standardized (z_) of the following:"
				while "`1'" != "" {
					qui  {
								capture drop w_`1'
								winsor2 `1',  cuts(1 99) by(year)
									gen w_`1' = `1'_w
									capture drop `1'_w
								lab var w_`1' "w_`1'"
								capture drop z_`1'
								egen z_`1' = std(w_`1')
								lab var z_`1' "z_`1'"
					}
					disp `"    `1'"'
					macro shift 
				}
				end

pwd

***********************************************************************
* County Level Analysis
***********************************************************************
use CountyLevelVars.dta, clear

****************************************************************
* Table 2: Lender Class Growth Rate Correlations
****************************************************************
	preserve
		capture drop *Type_5* *Type_6* *NonBk*
		qui foreach t in  1 2 3 4 5 6 7 8 9 10  { 
			capture rename w_Gr7_LenderType_`t'_nloan Gr7_LT_`t'
			capture rename w_Gr4_LenderType_`t'_nloan Gr4_LT_`t'
			capture rename w_S7_Sh_LenderType_`t'_nloan Sh7_LT_`t'
		}
		 
		qui foreach t in 23   { 
			capture rename w_Gr7_LenderType_`t'_nloan Gr7_LT_`t'
			capture rename w_G4_LenderType_`t'_nloan Gr4_LT_`t'
			capture rename w_S7_Sh_LenderType_`t'_nloan Sh7_LT_`t'
		}
			drop Gr7_LT_2 Gr7_LT_3  Gr4_LT_2 Gr4_LT_3
		lab var Gr7_LT_1 Big4
		lab var Gr7_LT_23 Large
		lab var Gr7_LT_4 Interm
		lab var Gr7_LT_7 Small
		lab var Gr7_LT_8 CredUnions
		lab var Gr7_LT_9 Shadow
		lab var Gr7_LT_10 Fintech
			
			pwcorr  Gr7_LT_* if year==2015,sig
			estpost correlate  Gr7_LT_* if year==2015, matrix 
			 esttab . , not unstack compress noobs nostar b(%5.2f)
			
	restore
************************************************
* Figure 3: The Big4 Retreat and County-Level Lender Class Growth
*			Quintile Growth by Lender Class
************************************************
	preserve 
		*drop Gr*
		local lt nloan
		local gr gs12
		global TXTopts placement(east) size(small)
		qui foreach Lender in 1 /*123  2 3*/ 23 4 /*5 6*/ 7 8 9 10 {
		    rename  w_Gr7_LenderType_`Lender'_`lt' Gr7_LT`Lender'
		}
		egen bin_Gr7_LT1 = xtile(Gr7_LT1) if year==2015,nq(5)
			tab bin_Gr7_LT1
			drop if mi(bin_Gr7_LT1)
		tabstat Gr7* ,by(bin_Gr7_LT1)
		collapse (mean) Gr* , by(bin_Gr7_LT1)
		list
		twoway line  Gr7_LT23     Gr7_LT4 Gr7_LT8  Gr7_LT10          Gr7_LT9  Gr7_LT7    Gr7_LT1, ///
			   name(LCgrowth_`lt', replace) ///
			ylabel(-8(4)12) xlabel(-35(5)-5)  legend(off)  ///
			xtitle(Big4 county-level growth (pps), size())  ytitle(Lender-class county-level growth (pps), size()) ///
			lcolor( `gr'  `gr' `gr'  orangebrown vermillion blue )  lpattern(l l l l l l) ///
 		text( -4.8 -9. "Large Banks"  /*-3.97*/ -3.9 -9 "Intermediate Banks"   2.3 -9 "Credit Unions"   , $TXTopts color(`gr')) ///
 			text( -6 -9 "Small Banks"     , $TXTopts  color(blue) ) ///
 			text(   5.4 -9 "Shadow Banks"  , $TXTopts  color(vermillion)) ///
 			text(  6.3 -9 "Fintech" , $TXTopts  color(orangebrown)) 
	restore
		

*********************************************
* Main Regressions
* Tables 4 and 5
*********************************************
	global FE state
	global CLVAR msa
	global REGTABLE b(%10.3f) p(%8.2f) scalars(N r2  "absvars Absorbed HDFE" "clustvar Clustered by" N_clust1   "widstat FirstStage Fstat" "exexog Instrument" ymean ysd) star(* 0.10 ** 0.05 *** 0.01)   ///
		addnote("`c(username)' ran on $S_DATE $S_TIME")  varwidth(32)  label

	global FILT nloan_stcou>=10
	global L7_CONTROL  L7.z_ln_total_pop L7.z_minority L7.z_PerCapInc L7.z_SP_Shr L7.z_ln_BHCs L7.z_HHIcnty L7.ln_num_lc_Banks_org_id L7.ln_num_lc_Nonbanks_org_id z_HP7yr_growth  z_age_median L7.w_Sh_AllBanks_nloan  
	global L7nAB_CONTROL  L7.z_ln_total_pop L7.z_minority L7.z_PerCapInc L7.z_SP_Shr L7.z_ln_BHCs L7.z_HHIcnty L7.ln_num_lc_Banks_org_id L7.ln_num_lc_Nonbanks_org_id z_HP7yr_growth  z_age_median   
	global L4_CONTROL  L4.z_ln_total_pop L4.z_minority L4.z_PerCapInc L4.z_SP_Shr L4.z_ln_BHCs L4.z_HHIcnty L4.ln_num_lc_Banks_org_id L4.ln_num_lc_Nonbanks_org_id z_HP4yr_growth   z_age_median  

		eststo clear
		qui foreach t in 7  9 10 23 4 8/*5 6*/  {
			*create variable that keeps only regression sample
			capture eststo gB4LT_`t'_OLS: reghdfe w_Gr7_LenderType_`t'_nloan  w_Gr7_LenderType_1_nloan  $L7_CONTROL if year==2015 & $FILT , absorb($FE ) cluster($CLVAR )
				capture gen sample_base_reg = e(sample)
				capture estadd ysumm
			capture eststo gB4LT_`t'_IV1: ivreghdfe w_Gr7_LenderType_`t'_nloan  (w_Gr7_LenderType_1_nloan = w_L7_Sh_LenderType_1_nloan)  $L7_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
				capture estadd ysumm
			capture eststo gB4LT_`t'_IV2: ivreghdfe w_Gr7_LenderType_`t'_nloan  (w_Gr7_LenderType_1_nloan = z_nloans_lawsuit_exposure)  $L7_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
				capture estadd ysumm
		}
		
	esttab gB4LT_*OLS  , mtitles $REGTABLE title(**OLS** Main Results [2008-2015] ) indicate("Controls =  $L7_CONTROL ") note("Controls =  $L7_CONTROL ")
	esttab gB4LT_*IV1  , mtitles $REGTABLE title(**IV** Lagged Big4 IV [2008-2015] ) indicate("Controls =  $L7_CONTROL ") note("Controls =  $L7_CONTROL ")
	esttab gB4LT_*IV2  , mtitles $REGTABLE title(**IV** Lawsuit IV [2008-2015] ) indicate("Controls =  $L7_CONTROL ") note("Controls =  $L7_CONTROL ")
											
											
	
**************************************************
* Figure 4: Graphical Raw First Stage of IVs 
**************************************************
	binscatter2 w_Gr7_LenderType_1_nloan  w_L7_Sh_LenderType_1_nloan	 if year==2015 , ///
			 ylabel(-40(10)0) xtitle("2008 Big4 Share") ytitle("Big4 Growth 2008-2015") title("" ) name(FirstStage, replace) reportreg 
	binscatter2 w_Gr7_LenderType_1_nloan  z_nloans_lawsuit_exposure	 if year==2015 ,  ///
			ylabel(-40(10)0) xtitle("Lawsuit Exposure (standardized)") ytitle("Big4 Growth 2008-2015") title("" ) name(FirstStageLaw, replace) reportreg 

	
**************************************************
* Figure 5: Mapping 2008 Big4 Share and 2008-2015 Big4 Growth
**************************************************
	preserve
		gen county = stcou 
		drop if mi(county)
		maptile w_L7_Sh_LenderType_1_nloan if year==2015 , geo(county2010) twopt(title("") name(Big4_2008,replace)  legend(size(small))  ) legformat(%4.0f) fcolor(BuRd)   
		maptile w_Gr7_LenderType_1_nloan if year==2015 , geo(county2010) twopt(title("") name(Big4_Growth,replace) legend(size(small)) ) legformat(%4.0f) fcolor(BuRd)   
	restore
	
*********************
* Table 1: Summary Statistics: County-Level Loan Growth by Lender Class
*********************
 	preserve
		 keep if sample_base_reg==1
		keep w_Gr7_LenderType_* w_Gr4_LenderType_*
		eststo clear
		qui foreach n in nloan  nloanNSoA nloanGSE   {
			foreach lt in 1 23 4 7 8 9 10 {
				capture drop LT_`lt'
				gen LT_`lt' = w_Gr7_LenderType_`lt'_`n'
			}
			disp "*** 2008-2015 `n' Growth"		 
		 eststo G7_`n': estpost tabstat LT_1 LT_23 LT_4 LT_7 LT_8 LT_9 LT_10 ,  stat(mean sd ) c(s)  
			foreach lt in 1 23 4 7 8 9 10 {
				capture drop LT_`lt'
				gen LT_`lt' = w_Gr4_LenderType_`lt'_`n'
			}
		 eststo G4_`n': estpost tabstat LT_1 LT_23 LT_4 LT_7 LT_8 LT_9 LT_10  , stat(mean sd ) c(s)  
		 }
		esttab G7* G4*, main(mean  %5.2f) aux(sd  %5.2f) nostar unstack mtitles title(2008-2015 Growth Overall, GSE, NSoA; then 2011-2015) label
	restore

**************************
* Tables 3 and A.1: Summary Statistics Tables 
**************************
qui {
preserve
	eststo clear
	gen Population_1k = L7.w_total_pop/1000
	gen Minority = L7.minority 
	gen Income_1k = L7.PerCapInc/1000
	gen Subprime = L7.SP_Shr/100
	gen Age = L7.w_age_median
	gen HPgrowth0815 = w_HP7yr_growth
	gen HHI = L7.HHIcnty
	gen Banks_phys = L7.BHCs_in_cnty
	gen Banks_lend = L7.num_lc_Banks_org_id
	gen Nonbanks_lend = L7.num_lc_Nonbanks_org_id
	
	*******************************************************
	*Table 3, Panel A: County Characteristics in 2008
	*******************************************************
	qui estpost tabstat Population_1k Minority Income_1k Subprime Age  HPgrowth0815 HHI Banks_phys Banks_lend Nonbanks_lend if sample_base_reg==1 ,stats(mean sd min q max n) c(s) 
	noisily esttab, cells("mean(fmt(2)) sd min p25 p50 p75 max count" ) noobs varwidth(20) title(County Characteristics in 2008)
	
	*******************************************************
	*Table 3, Panel B:  2008 County Mortgage Lending Share
	*******************************************************
	qui foreach lt in 23 4 7 8 9 10 {
		gen L7_Sh_LenderType_`lt'_nloan = L7.Sh_LenderType_`lt'_nloan if year==2015
	}
	lab var L7_Sh_LenderType_1_nloan Big4_Share_2008
	lab var L7_Sh_LenderType_23_nloan Large_Banks_Share_2008
	lab var L7_Sh_LenderType_4_nloan Intermediate_Banks_Share_2008
	lab var L7_Sh_LenderType_7_nloan Small_Banks_Share_2008
	lab var L7_Sh_LenderType_8_nloan Credit_Unions_Share_2008
	lab var L7_Sh_LenderType_9_nloan Shadow_Banks_Share_2008
	lab var L7_Sh_LenderType_10_nloan Fintech_Share_2008
	eststo clear
	qui estpost tabstat   L7_Sh_LenderType_1_nloan L7_Sh_LenderType_23_nloan L7_Sh_LenderType_4_nloan L7_Sh_LenderType_7_nloan L7_Sh_LenderType_8_nloan ///
		L7_Sh_LenderType_9_nloan L7_Sh_LenderType_10_nloan if sample_base_reg==1 ,stats(mean sd min p10 q p90 max n) c(s) 
	noisily esttab, cells("mean(fmt(2)) sd min p25 p50 p75 max count" ) noobs varwidth(30) title( 2008 County Mortgage Lending Share) label
	
	*******************************************************
	*Table A.1, Panel A: County Characteristics by 2008-2015 Big4 County-level Growth
	*******************************************************
	lab var w_Gr7_LenderType_1_nloan Big4_Growth_2008_2015
	eststo clear
	xtile Gr7_Big4_quintile = w_Gr7_LenderType_1_nloan if sample_base_reg==1, nq(5)
		 estpost tabstat   w_Gr7_LenderType_1_nloan Population_1k Minority Income_1k Subprime  Age  HPgrowth0815 HHI, by(Gr7_Big4_quintile) stat(mean p50) c(s) nototal
		noisily esttab ., main(mean) aux(p50)  noobs varwidth(30) title(County Characteristics by 2008-2015 Big4 County-level Growth, median in brackets)  unstack brackets label

	*******************************************************
	*Table A.1, Panel B: County Characteristics by 2008 Big4 County-level Origination Share
	*******************************************************
	lab var L7_Sh_LenderType_1_nloan Big4_Share_2008
	eststo clear
	xtile Sh08_Big4_quintile = L7_Sh_LenderType_1_nloan if sample_base_reg==1, nq(5)
		 estpost tabstat   L7_Sh_LenderType_1_nloan Population_1k Minority Income_1k Subprime  Age   HPgrowth0815 HHI, by(Sh08_Big4_quintile) stat(mean p50) c(s) nototal
		noisily esttab ., main(mean) aux(p50)  noobs varwidth(30) title(County Characteristics by 2008 Big4 County-level Origination Share, median in brackets)  unstack brackets label
		
restore
}

	
**************************
* Table A.2 Using Further Lags of Big4 Share as an Instrument for the Big4 Retreat
**************************
	eststo clear
	qui foreach t in   7  9 10 {
		eststo gLT_`t'_IV05: ivreghdfe w_Gr7_LenderType_`t'_nloan  (w_Gr7_LenderType_1_nloan = SH_PurRefi_Big4_2005)  $L7_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
			estadd ysumm
		eststo gLT_`t'_IV02: ivreghdfe w_Gr7_LenderType_`t'_nloan  (w_Gr7_LenderType_1_nloan = SH_PurRefi_Big4_2002)  $L7_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
			estadd ysumm
	}
	 esttab *05 *02  , mtitles $REGTABLE title(**IV-Alternative Lags 2005, 2002** [2008-2015] ) indicate("Controls =  $L7_CONTROL ") note("Controls =  $L7_CONTROL ")

		
*********************************************************************
*Table 6: Substitution in Balance Sheet Lending
*********************************************************************
	eststo clear
	 qui foreach t in /*123  2 3*/ 7 23 4 /*5 6*/ 9 10 8 /*8 9 10*/ {
		preserve
			foreach v in  z_ln_total_pop  z_minority z_PerCapInc z_SP_Shr z_ln_BHCs z_HHIcnty ln_num_lc_Banks_org_id ln_num_lc_Nonbanks_org_id w_Sh_AllBanks_nloan {
				gen L7_`v' = L7.`v'
			}
			global L7  L7_z_ln_total_pop  L7_z_minority L7_z_PerCapInc L7_z_SP_Shr L7_z_ln_BHCs L7_z_HHIcnty L7_ln_num_lc_Banks_org_id L7_ln_num_lc_Nonbanks_org_id  z_HP7yr_growth  z_age_median L7_w_Sh_AllBanks_nloan
			expand 2, gen(BS_Lending)
			tab BS_Lending
			gen w_Gr7_LT`t' = w_Gr7_LenderType_`t'_nloanNonBS if BS_Lending==0
				replace w_Gr7_LT`t' = w_Gr7_LenderType_`t'_nloanNSoA if BS_Lending==1
			egen BS_x_State = group(BS_Lending state_fips)
			gen w_Gr7_Big4nloan = w_Gr7_LenderType_1_nloan
			gen Gr7_Big4nloan_x_BS = w_Gr7_Big4nloan * BS_Lending
			gen L7_Sh_Big4nloan_x_BS = w_L7_Sh_LenderType_1_nloan * BS_Lending
				
			sort stcou year 
				 ivreghdfe w_Gr7_LT`t' (c.w_Gr7_Big4nloan Gr7_Big4nloan_x_BS = c.w_L7_Sh_LenderType_1_nloan L7_Sh_Big4nloan_x_BS)  $L7 /*$L7_CONTROL*/ if year==2015  & $FILT, absorb(BS_x_State ) cluster($CLVAR ) first
				eststo LT`t'_Gr7: ivreghdfe w_Gr7_LT`t' (c.w_Gr7_Big4nloan Gr7_Big4nloan_x_BS = c.w_L7_Sh_LenderType_1_nloan L7_Sh_Big4nloan_x_BS)  $L7 /*$L7_CONTROL*/ if year==2015  & $FILT, absorb(BS_x_State ) cluster($CLVAR ) 
		restore			
		}
	 esttab  , mtitles $REGTABLE noomit title(Substitution in Balance Sheet Lending )	 indicate("Controls =  $L7 ") note("Controls =  $L7 ")		
	 
 
*********************************************************************
* Table A.3: Exploiting within-Big4 variation in regulatory shocks
*********************************************************************
 	eststo clear
	qui foreach t in 7  9 10 23 4 8/*5 6*/  {
		capture eststo gB4LT_`t'_IVBoA: ivreghdfe w_Gr7_LenderType_`t'_nloan  (w_Gr7_LenderType_BoA_nloan = w_L7_Sh_LenderType_BoA_nloan) w_L7_Sh_LenderType_1_nloan  $L7nAB_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
			estadd ysumm
	}
	 esttab *BoA  , mtitles $REGTABLE title(Exploiting within-Big4 variation in regulatory shocks ) indicate("Controls =  $L7nAB_CONTROL ") note("Controls =  $L7nAB_CONTROL ")
  

***********************************
* Table 7: Shocks to the Costs of GSE Lending and Small Bank Growth
***********************************
	gen tGSE_Share2011 = 100*GSE_Share if year==2011
			egen GSE_Share2011 = mean(tGSE_Share2011),by(stcou)
			drop tGSE_Share2011
	gen tGSE_Share2008 = 100*GSE_Share if year==2008
			egen GSE_Share2008 = mean(tGSE_Share2008),by(stcou)
			drop tGSE_Share2008
			WinStd_tb GSE_Share2008 GSE_Share2011 GSE_p50Rank_2011 GSE_aveRank_2011  GSE_p50Rank_2011 

	capture gen nloans_OtherTopTenGSE_share2011 = nloans_TopTenGSE_share2011 - nloans_Big4GSE_share2011 - nloans_NonBkTopTenGSE_share2011
	foreach v in TopTenGSE Big4GSE  NonBkTopTenGSE OtherTopTenGSE {
		capture gen Sh_`v'_11 =  nloans_`v'_share2011 
	}
	WinStd_tb Sh_TopTenGSE_11 Sh_Big4GSE_11 Sh_NonBkTopTenGSE_11 Sh_OtherTopTenGSE_11
				
	capture gen nloans_OtherTop50GSE_share2011 = nloans_Top50GSE_share2011 - nloans_Big4GSE_share2011 - nloans_NonBkTop50GSE_share2011
	foreach v in Top50GSE Big4GSE  NonBkTop50GSE OtherTop50GSE {
	   capture gen Sh_`v'_11 =  nloans_`v'_share2011 
	}
	WinStd_tb Sh_Top50GSE_11 Sh_Big4GSE_11 Sh_NonBkTop50GSE_11 Sh_OtherTop50GSE_11
	gen Gr4_NonBkNotTop10 = 100*( (Sh_NonBkNotTop10nloanGSE*nloanGSE_stcou)/L4.nloanGSE_stcou )   - L4.Sh_NonBkNotTop10nloanGSE if year==2015

	eststo clear
	qui {
		*parity
		eststo par_7_GSE : ivreghdfe w_Gr4_LenderType_7_nloanGSE    w_nloans_TopTenGSE_share2011 $L4_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
							estadd ysumm
		eststo par_7_GSE2 : ivreghdfe w_Gr4_LenderType_7_nloanGSE   w_nloans_TopTenGSE_share2011 w_GSE_Share2011 $L4_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
							estadd ysumm
		eststo par_SmNon_GSE : ivreghdfe Gr4_NonBkNotTop10   w_nloans_TopTenGSE_share2011 w_GSE_Share2011 $L4_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
							estadd ysumm
		*level
		foreach lt in 7 /*23 4*/  {
		eststo lvl_`lt'_NSoA : ivreghdfe w_Gr4_LenderType_`lt'_nloanNSoA   				w_GSE_Share2011  $L4_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
							estadd ysumm
		eststo lvl_`lt'_NSoA2 : ivreghdfe w_Gr4_LenderType_`lt'_nloanNSoA   w_nloans_TopTenGSE_share2011 w_GSE_Share2011  $L4_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
							estadd ysumm
		}						
		*Placebo
		eststo, prefix(plac_7_Jum_): ivreghdfe w_Gr4_LenderType_7_nloanJumbo   w_nloans_TopTenGSE_share2011 w_GSE_Share2011 $L4_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
							estadd ysumm
	}
	noisily esttab  par_7* lvl* par_S* plac* , mtitles $REGTABLE title(**Small Bank Growth **Foreach Loan Segment,  2011-2015)   indicate( "Controls4yr=  $L4_CONTROL "  ) note("Controls =  $L4_CONTROL ")					
	

********************************************
* Table 8, Panel A: The Distinct Role of the Shocks to GSE Funding (Top 10)
********************************************
	qui foreach Lender in 7   {
	eststo clear
	foreach lt in n nGSE nNSoA   {
		eststo, prefix(Gr4_`lt'): ivreghdfe w_Gr4_LenderType_`Lender'_nloa`lt'  w_Sh_TopTenGSE_11 w_GSE_Share2011 $L4_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
			estadd ysumm
		eststo, prefix(Gr4_`lt'): ivreghdfe w_Gr4_LenderType_`Lender'_nloa`lt'  w_Sh_Big4GSE_11 w_GSE_Share2011 $L4_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
			estadd ysumm
		eststo, prefix(Gr4_`lt'): ivreghdfe w_Gr4_LenderType_`Lender'_nloa`lt'  w_Sh_NonBkTopTenGSE_11 w_GSE_Share2011 $L4_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
			estadd ysumm
		eststo, prefix(Gr4_`lt'): ivreghdfe w_Gr4_LenderType_`Lender'_nloa`lt'  w_Sh_OtherTopTenGSE_11 w_GSE_Share2011 $L4_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
			estadd ysumm
		eststo, prefix(Gr4_`lt'): ivreghdfe w_Gr4_LenderType_`Lender'_nloa`lt'  w_Sh_Big4GSE_11 w_Sh_NonBkTopTenGSE_11 w_Sh_OtherTopTenGSE_11 w_GSE_Share2011 $L4_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
			estadd ysumm
		   }
	noisily esttab *n1 *n5 *6 *10 *11 *15 , mtitles $REGTABLE title(**G-Fee Shock TopTen **LenderType `Lender'**Foreach Loan Segment, 2011-2015) order(w_Sh*)  indicate( "Controls4yr=  $L4_CONTROL " ) note("Controls =  $L4_CONTROL ")	compress				
	 }


********************************************
* Table 8, Panel B: The Distinct Role of the Shocks to GSE Funding (Top 50)
********************************************
	qui foreach Lender in 7   {
		eststo clear
		foreach lt in n nGSE nNSoA   {
			eststo, prefix(Gr4_`lt'): ivreghdfe w_Gr4_LenderType_`Lender'_nloa`lt'  w_Sh_Top50GSE_11  w_GSE_Share2011  $L4_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
				estadd ysumm
			eststo, prefix(Gr4_`lt'): ivreghdfe w_Gr4_LenderType_`Lender'_nloa`lt'  w_Sh_Big4GSE_11 w_GSE_Share2011 $L4_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
				estadd ysumm
			eststo, prefix(Gr4_`lt'): ivreghdfe w_Gr4_LenderType_`Lender'_nloa`lt'  w_Sh_NonBkTop50GSE_11  w_GSE_Share2011  $L4_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
				estadd ysumm
			eststo, prefix(Gr4_`lt'): ivreghdfe w_Gr4_LenderType_`Lender'_nloa`lt'  w_Sh_OtherTop50GSE_11  w_GSE_Share2011  $L4_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
				estadd ysumm
			eststo, prefix(Gr4_`lt'): ivreghdfe w_Gr4_LenderType_`Lender'_nloa`lt'  w_Sh_Big4GSE_11 w_Sh_NonBkTop50GSE_11 w_Sh_OtherTop50GSE_11  w_GSE_Share2011  $L4_CONTROL if year==2015  & $FILT, absorb($FE ) cluster($CLVAR )
				estadd ysumm
			   }
		noisily esttab  *n1 *n5 *6 *10 *11 *15   , mtitles $REGTABLE title(**G-Fee Shock Top50 **LenderType `Lender'**Foreach Loan Segment, 2011-2015) order(w_Sh*)    indicate( "Controls4yr=  $L4_CONTROL " ) note("Controls =  $L4_CONTROL ")	compress				
	 }

